package com.project.controller;

import com.github.pagehelper.PageInfo;
import com.project.bean.MainPostBean;
import com.project.service.IMainPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@RequestMapping("mainPost")
public class MainPostController {
    @Autowired
    private IMainPostService service;
    @RequestMapping("findByItem")
    public PageInfo<MainPostBean> findByItem(@RequestParam(value = "pageNo",defaultValue = "1")
     int channelId,int pageNo, String theme, String author, LocalDate startDate, LocalDate endDate){
        return service.findByItem(channelId, pageNo, theme, author, startDate, endDate);
    }
    @RequestMapping("add")
    public String add(MainPostBean mainPostBean){
        service.add(mainPostBean);
        return "ok";
    }
    @RequestMapping("findById")
    public MainPostBean findById(int id){
        return service.findById(id);
    }
}
